var e = null, l = null, o = null, r = null, c = 0, f = 0, g = getApp(), h = null, cssj = new Array(), cssj2 = new Array();
var tms, tps, bjtps, xxjss, nums, xpzcss, zdys;
var jtggzt = 0;
Page({
    data: {
        prurl: null,
        hidden: !0,
        hidden1: !1,
        ggxx: "您的测试报告正在生成，点击下方按钮即可查看测试结果。"
    },
    onLoad: function (m) {
        jtggzt = 0;
        wx.showShareMenu();
        //跳转页面参数
        tms = m.tms, tps = m.tps, bjtps = m.bjtps, xxjss = m.xxjss, nums = m.nums, xpzcss = m.xpzcss, zdys = m.zdys;
        //参数
        switch (wx.showLoading({
            title: "生成报告中",
            mask: "true",
        }), c = 0, f = 0, e = m.csm, l = m.dfjs, cssj[0] = m.bq1, cssj[1] = m.bq2, cssj[2] = m.bq3, cssj[3] = m.bq4, cssj[4] = m.bq5, cssj[5] = m.bq6, cssj[6] = m.bq7, cssj[7] = m.bq8, cssj[8] = m.bq9, cssj[9] = m.bq10, cssj[10] = m.bq11, cssj[11] = m.bq12,
        cssj2[0] = m.pf1, cssj2[1] = m.pf2, cssj2[2] = m.pf3, cssj2[3] = m.pf4, cssj2[4] = m.pf5, cssj2[5] = m.pf6, cssj2[6] = m.pf7, cssj2[7] = m.pf8, cssj2[8] = m.pf9, cssj2[9] = m.pf10, cssj2[10] = m.pf11, cssj2[11] = m.pf12,
        o = m.df, r = m.nickname, h = m.bjtp) {
            case "1":
                h = "/images/xpzbjt.jpg";
                break;
        }
        var d = new Promise(function (e, l) {
            wx.getImageInfo({
                src: h,
                success: function (l) {
                    c = 1, e(l);
                }
            });
        }), x = new Promise(function (e, l) {
            wx.getImageInfo({
                src: g.globalData.userInfo.avatarUrl,
                success: function (l) {
                    f = 1, e(l);
                },
                fail: function () {
                    wx.showToast({
                        title: "连接服务器失败，请重新载入该页面！",
                        icon: "none",
                        duration: 2e3
                    });
                }
            })
        }), xpz1 = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xpz1.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        }), xpz2 = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xpz2.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        }), xpz3 = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xpz3.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        }), xpz4 = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xpz4.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        }), xpz5 = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xpz5.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        }), xcxm = new Promise(function (e, l) {
            wx.getImageInfo({
                src: "/images/xcxm.png",
                success: function (l) {
                    f = 1, e(l);
                }
            });
        });
        Promise.all([d, x, xpz1, xpz2, xpz3, xpz4, xpz5, xcxm]).then(function (c) {
            var f = wx.createCanvasContext("shareImg");
            f.drawImage("../../" + c[0].path, 0, 0, 320, 480)
            f.drawImage(c[1].path, 28, 55, 50, 50)
            f.drawImage("../../" + c[7].path, 5, 420, 65, 60)
            f.setTextAlign("center")
            f.setFillStyle("black")
            f.setFontSize(16)
            for (let pzs = 0, pzx = 15, pzy = 120, pf = 5; pzs < 12; pzs++ , pzx = pzx + 80) {
                if (cssj[pzs] == "null") { break }
                if (pzs % 4 == 0 && pzs != 0) { pzx = 15; pzy = pzy + 90 }
                if (cssj2[pzs] == "1") { pf = 1 }
                if (cssj2[pzs] == "2") { pf = 2 }
                if (cssj2[pzs] == "3") { pf = 3 }
                if (cssj2[pzs] == "4") { pf = 4 }
                if (cssj2[pzs] == "5") { pf = 5 }
                f.drawImage("../../" + c[pf + 1].path, pzx, pzy, 50, 50)
                f.fillText(cssj[pzs], pzx + 25, pzy + 70)
            }
            f.setTextAlign("left")
            f.fillText("名字：" + r, 88, 70)
            f.fillText(l, 88, 100)
            f.setFillStyle("blue")
            f.setFontSize(26)
            f.fillText(o, 180, 102)
            f.setFillStyle("red")
            f.setTextAlign("center")
            f.setFontSize(32)
            f.fillText(e, 160, 37)
            f.setFontSize(18)
            f.setFillStyle("black")
            f.setTextAlign("left")
            f.fillText("长按识别小程序码", 76, 440)
            f.fillText("获取你的小瓶子", 76, 470)
            f.stroke()
            f.draw();
        })
        setTimeout(function () {
            wx.hideLoading();
        }, 1e3);
    },
    onReady: function () { },
    onPullDownRefresh: function () { },
    onShareAppMessage: function () {//分享代码
        return {
            title: "我完成了“" + e + "”你也来评测一下吧！",
            path: "/pages/main/main?tm=" + tms + "&tp=" + tps + "&bjtp=" + bjtps + "&xxjs=" + xxjss + "&num=" + nums + "&xpzcs=" + xpzcss + "&zdy=" + zdys + "&csrs=null",
            imageUrl: this.data.prurl
        };
    },
    share: function () {
        jtggzt = 0;
        var e = this;
        1 == c && 1 == f ? wx.canvasToTempFilePath({
            x: 0,
            y: 0,
            width: 320,
            height: 480,
            destWidth: 960,
            destHeight: 1440,
            canvasId: "shareImg",
            success: function (l) {
                e.setData({
                    hidden: !1,
                    hidden1: !0,
                    prurl: l.tempFilePath
                })
            }
        }) : wx.showModal({
            content: "十分抱歉，获取报告内容时出现了错误！请返回上一页重新点击生成按钮。",
            showCancel: !1,
            confirmText: "好的",
            confirmColor: "#333"
        });
    },
    save: function () {
        var e = this;
        wx.saveImageToPhotosAlbum({
            filePath: e.data.prurl,
            success: function (e) {
                wx.showModal({
                    content: "图片已保存到相册，赶紧晒一下吧",
                    showCancel: !1,
                    confirmText: "好的",
                    confirmColor: "#333"
                });
            },
            fail: function () {
                wx.showToast({
                    title: "保存图片失败！",
                    icon: "none",
                    duration: 3e3
                });
            }
        });
    },
});